home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / Open Transport / Sample Code / DTS Sample Code / OTTraceRouteSample / Read Me About Traceroute Sample < prev   
Encoding:
Text File  |  1996-11-19  |  2.6 KB  |  47 lines  |  [TEXT/ttxt]

  1. Open Transport Traceroute Sample
  2.  
  3. 1.0b1
  4.  
  5. This sample is a quick demonstration of how to implement traceroute on top of the Open Transport native APIs.  The sample is useful because it gives a good demonstration of the setting the IP TTL option and of using a "rawip" endpoint to receive and process ICMP packets.
  6.  
  7. Theory of Operation
  8.  
  9. Traceroute exploits two well supported features of the Internet Control Message Protocol (ICMP) protocol.  The first is that, whenever a router kills a packet because the Time To Live (TTL) has expired, the router is required to send an ICMP time exceeded packet back to the source.  The second is that, whenever a host gets a packet addressed to a port on which no one is listening, the host is required to send an ICMP port unreachable packet back to the source.
  10.  
  11. Traceroute works by sending small UDP datagrams to the destination machine with increasing TTLs.  This causes each router encountered to generate the ICMP time exceeded, which allows you to determine the address of each router along the way.  The process terminates when you get an ICMP port unreachable (which means the final host attempted to deliver the packet but no one was listening) or when some user configurable limit on the TTL has been reached.
  12.  
  13. Anyone interested in more details about the traceroute concept should consult a TCP/IP reference.
  14.  
  15. Implementation Details
  16.  
  17. The code is actually very easy.  The big simplifying assumption, is that everything is run in synchronous mode.  The only remaining difficulties are:
  18.  
  19. • setting the TTL option on outgoing UDP datagrams (see DoNegotiateIP_TTLOption),
  20. • clearing incoming T_UDERR errors on the UDP endpoint (see SendUDPWithTTL),
  21. • receiving and interpreting ICMP packets (see WaitAndPrintICMPs).
  22.  
  23. The code was written with CodeWarrior 9 and tested on multiple machines running a variety of versions of Open Transport.
  24.  
  25. Caveats
  26.  
  27. The sample is not a complete traceroute implementation.  It lacks in the following areas:
  28.  
  29. • Matching ICMP response to their corresponding original UDP packets.
  30. • Issuing multiple traces for each step, just in case one gets lost in the network.
  31. • Timing responses.
  32. • User interface.
  33. • Dealing with extraordinary conditions, like IP options in ICMP packets.
  34. • Other things that I'm not aware of because I'm not a TCP/IP guru.
  35. • The ability to traceroute anywhere except 130.43.2.2 (ie “apple.com”)  (–:
  36.  
  37. Credits
  38.  
  39. I’d like to express my thanks to that developer (you know who you are) who goaded me into writing this sample by saying that it couldn’t be done.
  40.  
  41. Share and Enjoy
  42.  
  43. Quinn "The Eskimo!"
  44. Apple Developer Technical Support • Networking, Communications, Hardware
  45.  
  46. 27 June 1996
  47.